﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VOL.Entity.DomainModels;

namespace VOL.demo.IServices.wms.ReturnOrder
{
    public interface IReturnOrderIServices
    {
        /// <summary>
        /// 添加退货单和退货明细（使用DTO，自动设置系统字段）
        /// </summary>
        /// <param name="createDto">退货单和退货明细创建DTO</param>
        /// <returns>添加结果</returns>
        Task<bool> AddWithDetailsAsync(ReturnOrderWithDetailsCreateDto createDto);
        /// <summary>
        /// 分页查询退货单
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="whereExpression">查询条件</param>
        /// <returns>分页结果</returns>
        Task<(List<returnordermodel> Data, int TotalCount)> GetPageListAsync(int pageIndex, int pageSize, 
            Expression<Func<returnordermodel, bool>> whereExpression = null);

        /// <summary>
        /// 根据ID获取退货单
        /// </summary>
        /// <param name="id">退货单ID</param>
        /// <returns>退货单信息</returns>
        Task<returnordermodel> GetByIdAsync(long id);

        /// <summary>
        /// 更新退货单
        /// </summary>
        /// <param name="entity">退货单实体</param>
        /// <returns>更新结果</returns>
        Task<bool> UpdateAsync(returnordermodel entity);

        /// <summary>
        /// 删除退货单
        /// </summary>
        /// <param name="id">退货单ID</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteAsync(long id);

        /// <summary>
        /// 批量删除退货单
        /// </summary>
        /// <param name="ids">退货单ID列表</param>
        /// <returns>删除结果</returns>
        Task<bool> DeleteRangeAsync(long[] ids);

        /// <summary>
        /// 获取退货单联查结果（包含供应商名称、部门名称、客户名称）
        /// </summary>
        /// <param name="id">退货单ID</param>
        /// <returns>退货单联查结果</returns>
        Task<ReturnOrderWithRelations> GetWithRelationsAsync(long id);
        
        /// <summary>
        /// 获取进货单联查列表（包含供应商名称、部门名称、客户名称）
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录数</param>
        /// <returns>分页结果</returns>
        Task<(List<PurchaseOrderWithRelation> Data, int TotalCount)> GetPurchaseOrderListAsync(int pageIndex, int pageSize);
        
        /// <summary>
        /// 根据进货单编号获取进货单信息（包含供应商、联系人、联系方式、部门、进货人）
        /// </summary>
        /// <param name="orderCode">进货单编号</param>
        /// <returns>进货单信息</returns>
        Task<PurchaseOrderWithRelation> GetPurchaseOrderByCodeAsync(string orderCode);
        
        /// <summary>
        /// 根据进货单号获取进货明细列表（包含货品信息）
        /// </summary>
        /// <param name="orderCode">进货单号</param>
        /// <returns>进货明细列表</returns>
        Task<List<PurchaseOrderItemWithProductModel>> GetPurchaseOrderItemsByCodeAsync(string orderCode);

        /// <summary>
        /// 分页查询退货单联查结果（包含供应商名称、部门名称、客户名称）
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="whereExpression">查询条件</param>
        /// <returns>分页结果</returns>
        Task<(List<ReturnOrderWithRelations> Data, int TotalCount)> GetPageListWithRelationsAsync(
            int pageIndex, 
            int pageSize, 
            Expression<Func<returnordermodel, bool>> whereExpression = null);
    }
}